<style>
    .layui-form .layui-form-item .layui-inline .layui-form-label {
        width: 150px;
    }
    .layui-form .layui-form-item .layui-inline input{
        width: 200px;
    }
</style>
<form class="layui-form seller-form" action="">
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">Create Time：</label>
            <div class="layui-input-inline seller-inline-4">
                <input type="text" name="datetime" id="datetime" placeholder="start_time _ end_time" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-sm" lay-submit lay-filter="*"><i class="iconfont icon-chaxun"></i>Search</button>
            </div>
        </div>
    </div>
</form>
<div class="table-body">
    <table id="balanceTable" lay-filter="balanceTable"></table>
</div>
<script>
    layui.use(['form', 'laydate', 'table',], function () {
        var laydate = layui.laydate,
            form = layui.form,
            table = layui.table; //表格
        //时间插件
        laydate.render({
            elem: '#datetime',
            range: '_',
            format: 'yyyy-MM-dd'
        });
        var tableIn = table.render({
            elem: '#balanceTable',
            height: 'full-99',
            cellMinWidth: '80',
            // totalRow: true,
            method: 'post',
            url: "{:url('contactUs')}",
            id: 'balanceTable',
            cols: [[
                { type: 'numbers'},
                { field: 'first_name',  align: 'left', title: 'first_name',width: 120},
                { field: 'last_name',  align: 'left', title: 'last_name',width: 120},
                { field: 'email',  align: 'left', title: 'Email'},
                { field: 'employees',  align: 'left', title: 'Employees' ,width:120},
                { field: 'company',  align: 'left', title: 'company',width: 160},
                { field: 'help_text',  align: 'left', title: 'Help Text'},
                { field: 'ip',  align: 'left', title: 'Ip' ,width: 140},
                { field: 'language',  align: 'left', title: 'Language' ,width: 150},
                { field: 'remark',  align: 'left', style:'color:green;font-weight:bold', title: 'Remark'},
                { align: 'left', title: 'Create Time',width:180,
                    templet: function (d) {
                        return layui.util.toDateString(d.create_time * 1000, "yyyy-MM-dd HH:mm:ss");
                    }
                },
                { field: 'option', title: 'Action', templet: function (d) {
                        return '<a class="layui-btn layui-btn-xs editRemark" data-id="' + d.id + '">Remark</a>';
                    }, align: 'center', width: 100
                },
            ]],
            page: true,
            limit: 20,
            limits: [20, 50, 100],
        });
        form.on('submit(*)', function (data) {
            layui.table.reload('balanceTable', {
                where: data.field
                , page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
        //余额编辑
        $(document).on('click', '.editRemark', function () {
            var id = $(this).attr('data-id');
            JsGet("{:url('editRemark')}?type=2&id="+id, function(e){
                if(e.status == 1){
                    layer.open({
                        type: 1,
                        title: 'Edit Remark',
                        area: ['500px', '466px'], //宽高
                        content: e.datas,
                        btn:['Confirm','Close'],
                        yes:function (index,layero) {
                            var thedata = $('.operationForm').serialize();
                            var remark   = $("#remark").val();
                            if (remark == '' || !remark) {
                                layer.msg("Please input in Remark" , {icon:2,time:1500});
                                return false;
                            }
                            JsPost('{:url("editRemark")}', thedata,function (re) {
                                if(re.code >0){
                                    layer.msg(re.msg , {icon:1,time:1500});
                                    layer.close(index);
                                    tableIn.reload({
                                        page:{
                                            curr :1
                                        }
                                    });
                                }else{
                                    layer.msg(re.msg, {icon:2,time:1500});
                                }
                            });
                        }
                    });
                }else{
                    layer.msg(e.msg);
                }
            });
        });
    });
</script>